unit uniGroundSeaSegment;

interface

uses
  uniGround,
  uniGroundSegment,
  gl,
  Classes;

type

  { GroundSeaSegment }

  GroundSeaSegment = class(GroundSegment)
  public
    vert: array[0..3, 0..2] of Single;

    constructor Create(p, s: array of Single; prnt: Ground);
    destructor Destroy; override;

    procedure drawGL;override;
  end;

implementation

uses
  uniDefine;

{ GroundSeaSegment }

constructor GroundSeaSegment.Create(p, s: array of Single; prnt: Ground);
var
  a: Single;
begin
  inherited Create(p, s, prnt);

  a := 1.0 + (FRAND * 0.5);
  vert[0][0] := a * s[0]; a := 1.0 + (FRAND * 0.5);
  vert[1][0] := -a * s[0]; a := 1.0 + (FRAND * 0.5);
  vert[2][0] := a * s[0]; a := 1.0 + (FRAND * 0.5);
  vert[3][0] := -a * s[0]; a := 1.0 + (FRAND * 0.5);
  vert[0][1] := a * s[1]; a := 1.0 + (FRAND * 0.5);
  vert[1][1] := a * s[1]; a := 1.0 + (FRAND * 0.5);
  vert[2][1] := -a * s[1]; a := 1.0 + (FRAND * 0.5);
  vert[3][1] := -a * s[1]; a := 1.0 + (FRAND * 0.5);
  vert[0][2] := 0.0;
  vert[1][2] := 0.0;
  vert[2][2] := 0.0;
  vert[3][2] := 0.0;
end;

destructor GroundSeaSegment.Destroy;
begin
  inherited;
end;

procedure GroundSeaSegment.drawGL;
begin
  glPushMatrix;
  glTranslatef(pos[0], pos[1], pos[2]);
  glBindTexture(GL_TEXTURE_2D, parent.tex[Integer(Base)]);
  glBegin(GL_TRIANGLE_STRIP);
  glTexCoord2f(1.0, 0.0); glVertex3fv(@vert[0]);
  glTexCoord2f(0.0, 0.0); glVertex3fv(@vert[1]);
  glTexCoord2f(1.0, 1.0); glVertex3fv(@vert[2]);
  glTexCoord2f(0.0, 1.0); glVertex3fv(@vert[3]);
  glEnd;
  glPopMatrix;
end;

end.

